package com.example.myapplication;
import static com.example.myapplication.DataBaseHelper.getInstance;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;

import org.apache.tools.ant.taskdefs.War;

public class LevelupDialog extends Dialog implements
        android.view.View.OnClickListener {
    private DataBaseHelper databaseHelper;
    private WarRecord war;
    public Activity c;
    public Dialog d;
    public Button yes, no;

    public LevelupDialog(Activity a, WarRecord war) {
        super(a);
        // TODO Auto-generated constructor stub
        this.c = a;
        this.war=war;
    }

    @SuppressLint("MissingInflatedId")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.dialog_levelup);
        yes = (Button) findViewById(R.id.btn_yes);
        no = (Button) findViewById(R.id.btn_no);
        yes.setOnClickListener(this);
        no.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.btn_yes) {
            databaseHelper = getInstance(this.c);


            if (war != null) {
                war=databaseHelper.getNextWar(war.getId());
                Intent intent = new Intent(this.c, ChessBoardActivity.class);//这边没有解决
                intent.putExtra("WARID", war.getId());//intent.putExtra("msg", msg);将数据传至另一个界面
                this.c.startActivity(intent);
            }

            }
            if (v.getId() == R.id.btn_no) {
                c.finish();

            }
            dismiss();
        }
    }


